package com.demo2do.boyle.common.entity.customer.wallet;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.alibaba.fastjson.annotation.JSONField;
import com.demo2do.boyle.common.entity.aduser.order.PayType;

/**
 * 
 * @author Wilson leo
 */
@Entity
@Table(name = "wallet_record")
public class WalletRecord {

    @Id
    @GeneratedValue
    private Integer id;

    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    @JSONField(serialize = false)
    private Wallet wallet;

    /** 发生时间 */
    private Date occurTime;

    /** 类型 */
    @Enumerated(EnumType.ORDINAL)
    private RecordType type;

    /** 涉及金额 */
    private int money;

    private Date createTime;
    
    private Integer businessId;

    @Column(name = "is_deleted")
    private boolean disabled;

    @Column(name = "is_read")
    private boolean read;
    
    @Enumerated(EnumType.ORDINAL)
    private PayType payType;
    
    /**
	 * The default constructor
	 */
	public WalletRecord() {
		
	}
	
	/**
	 * The constructor using fields
	 * 
	 * @param wallet
	 * @param type
	 * @param payType
	 */
	public WalletRecord(Wallet wallet, RecordType type, PayType payType) {
		this.wallet = wallet;
		this.type = type;
		this.payType = payType;
		this.occurTime = new Date();
	}
	
	/**
	 * Initialize with money
	 * 
	 * @param balance
	 * @return
	 */
	public WalletRecord initialize(int money) {
		this.money = money;
		return this;
	}
	
	/**
	 * Initialize with balance and businessId
	 * 
	 * @param balance
	 * @param businessId
	 * @return
	 */
	public WalletRecord initialize(int money, Integer businessId) {
		this.money = money;
		this.businessId = businessId;
		return this;
	}

	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * @return the wallet
	 */
	public Wallet getWallet() {
		return wallet;
	}

	/**
	 * @return the occurTime
	 */
	public Date getOccurTime() {
		return occurTime;
	}

	/**
	 * @return the type
	 */
	public RecordType getType() {
		return type;
	}

	/**
	 * @return the money
	 */
	public int getMoney() {
		return money;
	}

	/**
	 * @return the createTime
	 */
	public Date getCreateTime() {
		return createTime;
	}

	/**
	 * @return the businessId
	 */
	public Integer getBusinessId() {
		return businessId;
	}

	/**
	 * @return the disabled
	 */
	public boolean isDisabled() {
		return disabled;
	}

	/**
	 * @return the read
	 */
	public boolean isRead() {
		return read;
	}

	/**
	 * @return the payType
	 */
	public PayType getPayType() {
		return payType;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @param wallet the wallet to set
	 */
	public void setWallet(Wallet wallet) {
		this.wallet = wallet;
	}

	/**
	 * @param occurTime the occurTime to set
	 */
	public void setOccurTime(Date occurTime) {
		this.occurTime = occurTime;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(RecordType type) {
		this.type = type;
	}

	/**
	 * @param money the money to set
	 */
	public void setMoney(int money) {
		this.money = money;
	}

	/**
	 * @param createTime the createTime to set
	 */
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	/**
	 * @param businessId the businessId to set
	 */
	public void setBusinessId(Integer businessId) {
		this.businessId = businessId;
	}

	/**
	 * @param disabled the disabled to set
	 */
	public void setDisabled(boolean disabled) {
		this.disabled = disabled;
	}

	/**
	 * @param read the read to set
	 */
	public void setRead(boolean read) {
		this.read = read;
	}

	/**
	 * @param payType the payType to set
	 */
	public void setPayType(PayType payType) {
		this.payType = payType;
	}
	
}
